package com.login.controller;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class LoginCommandValidator implements Validator {

    public void validate(Object target, Errors errors) {
        //비어있거나 공백이있으면 돌려보냄
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id", "required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "loginType", "required");
    }

    public boolean supports(Class<?> clazz) { 
        return LoginCommnad.class.isAssignableFrom(clazz);
    }    
}